<?php

define("TABLE_QUOTE", '`');
define("FIELD_QUOTE", '`');

if (empty($dbPort)){
	$dbPort = 3306;
}

	//open database connection
try {
    $dbh = new PDO("mysql:host=$dbServer;dbname=$dbDatabase;port=$dbPort", $dbUsername, $dbPassword);
    }
catch(PDOException $e)
    {
    echo $e->getMessage();
    }
	
// ------ Functions with DB Engine specific implementations 

function get_array_limitquery($thequery, $start = 0, $limit = 'MAX'){
	global $dbh;
	if($limit != 'MAX'){
		$thequery .= " LIMIT $start, $limit ";
	}
	try{
	    /*** fetch into an PDOStatement object ***/
		$stmt = $dbh->query($thequery);

		/*** echo number of columns ***/
		$result = $stmt->fetchall(PDO::FETCH_ASSOC);
				
	}
	catch(PDOException $e)
		{	
		echo $e->getMessage();
		}	
	return $result;
}
	

function limit_query($thequery, $start = 0, $limit = 'MAX'){
	if($limit != 'MAX'){
		return $thequery .= " LIMIT $start, $limit ";
	}
	else{
		return $thequery;
	}

}
	

	
	
?>